import sys
import _build

# Set up the compilation environment.
# Note: individual programs will link only the objects they need from these
# libraries, so it's OK to just always compile all of them.
_build.Using('_sdl')
_build.Using('_web')
_build.Using('_paste')
_build.Using('_ncurses')
_build.Using('_common')
if sys.platform == 'darwin':
#	_build.env.Append(CCFLAGS = ['-I/Library/Frameworks/SDL.framework/Headers']);
#	_build.env.Append(CCFLAGS = ['-I/Library/Frameworks/SDL_image.framework/Headers']);
#	_build.env.Append(LINKFLAGS = ['-framework', 'SDL']);
#	_build.env.Append(LINKFLAGS = ['-framework', 'SDL_image']);
	_build.env.ParseConfig('sdl-config --cflags --libs')
	_build.env.Append(LIBS = ['SDL_image'])
	_build.env.Append(LINKFLAGS = ['-framework', 'Cocoa']);
else:
	_build.env.ParseConfig('sdl-config --cflags --libs')
	_build.env.Append(LIBS = ['SDL_image', 'X11'])
_build.env.Append(LIBS = ['curses', 'curl'])

_build.targets = BUILD_TARGETS

_build.Binary('calc')
_build.Binary('ending')
_build.Binary('Gringotts')
_build.Binary('Hexie')
_build.Binary('hsiloP')
_build.Binary('HyperList')
_build.Binary('kwirki')
_build.Binary('Mirth')
_build.Binary('pb')
_build.Binary('scout')

# Special code for 'weather', which installs multiple binaries:
_build.env.Alias('weather', [
	_build.yieldDir + 'bin/weatherscrape',
	_build.yieldDir + 'bin/tableprint'])
weatherscrape = _build.env.Program(_build.yieldDir + 'bin/weatherscrape', [
	_build.yieldDir + 'weatherscrape/weatherscrape.cpp'])
tableprint = _build.env.Program(_build.yieldDir + 'bin/tableprint', [
	_build.yieldDir + 'weatherscrape/tableprint.cpp'])
if 'weather' in BUILD_TARGETS or 'all' in BUILD_TARGETS:
	_build.env.Install('/usr/local/bin', [
		weatherscrape, 
		tableprint, 
		'weatherscrape/forecast', 
		'weatherscrape/weather'])
	_build.env.Alias('install', '/usr/local/bin')

# Special code for 'note', which installs multiple binaries:
_build.env.Alias('note', [
	_build.yieldDir + 'bin/note',
	_build.yieldDir + 'bin/notetaker'])
note = _build.env.Program(_build.yieldDir + 'bin/note', [
	_build.yieldDir + 'NoteTaker/console.cpp',
	_build.yieldDir + 'NoteTaker/note.cpp'])
notetaker = _build.env.Program(_build.yieldDir + 'bin/notetaker', [
	_build.yieldDir + 'NoteTaker/main.cpp',
	_build.yieldDir + 'NoteTaker/note.cpp'])
if 'note' in BUILD_TARGETS or 'all' in BUILD_TARGETS:
	_build.env.Install('/usr/local/bin', [note, notetaker])
	_build.env.Alias('install', '/usr/local/bin')

_build.env.Alias('all', _build.yieldDir + 'bin/scout')

